<?php
/**
 * 老客户
 *
 *
 */
class shipping_user_model extends Model
{
    var $id;
	
	var $name_pingyin;
	
	var $name;
	
	var $telephone;
	
	var $type;
 

	function __construct()
    {
        parent::Model();
    }

	// --------------------------------------------------------------------

    /**
	 * load by id
	 *
	 *
	 */	
    function load($id,$type)
    {
        if (!$id){
            return array();
        }
        $this->db->from('shipping_user');
		$where = "lower(type)='".$type."' AND (name_pingyin like '%".$id."%' OR telephone like '%".$id."%')";
        $this->db->where($where);
        //$this->db->like('name_pingyin',$id);
        //$this->db->or_like('telephone',$id);

          
        if ($row = $this->db->get()){
 
            
            return $row;
        }

        return array();
    }

    /**
     * load by id for trader
     * 
     */
    
    function load_all($name_pingyin,$telephone,$type)
    {
        if (!$name_pingyin || !$telephone||!$type){
            return array();
        }

        $query = $this->db->get_where('shipping_user',array('name_pingyin' => $name_pingyin,'telephone' => $telephone,'type'=>$type));

        if ($row = $query->row_array()){
 
            
            return $row;
        }

        return array();
    }    
	// --------------------------------------------------------------------

    /**
	 * 创建
	 *
	 *
	 */	
    function create()
    { 
		 
         
		$this->db->set('name_pingyin', $this->name_pingyin);
		$this->db->set('name',$this->name);
		$this->db->set('telephone', $this->telephone);
		$this->db->set('type', $this->type);
  
	 
              
        return $this->db->insert('shipping_user');
    }
 
 
	 



	 
    
    
    
     
 
}